package io;

import java.io.*;
import java.util.Scanner;

public class Test4 {
    public static void main(String[] args) throws FileNotFoundException {
        File file = new File("note2.txt");
        FileOutputStream fos = new FileOutputStream(file);//文件输出流
        OutputStreamWriter osw = new OutputStreamWriter(fos);//缓冲输出流
        BufferedWriter bfw = new BufferedWriter(osw);//字符转换流
        PrintWriter pw = new PrintWriter(bfw,true);//PrintWriter流
        Scanner scan = new Scanner(System.in);
        while (true){
            System.out.println("请输入字符:");
            String line = scan.nextLine();
            if (line.equals("exit")){
                break;
            }
            pw.println(line);
//            pw.flush();
        }
        System.out.println("写入完成");
        pw.close();



    }
}
